package com.jgj.cloud.user.controller;

import com.jgj.cloud.user.entity.User;
import com.jgj.cloud.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/findUserById/{userId}")
    public User findUserById(@PathVariable("userId") Long userId){
        return userService.findUserById((userId));
    }

    @GetMapping("/testToken/{userId}")
    public User findUser(@PathVariable("userId") Long userId,
                         @RequestHeader("token") String  token){
        log.info("用户微服务的findUser方法执行了,获取请求头参数token:{}", token);
        return userService.findUserById((userId));
    }
}
